import React, { Component } from 'react';
import '../../../../css.css'
class CommentList extends Component {
  state = {}
  // 删除
  del = (index)=>{
    this.props.list.splice(index,1)
    this.setState({
      list:this.props.list
    })
  }
  
  render() { 
    return ( <>
         <div>
            {
              this.props.list.map((item,index)=>{
                return <>
                  <ul key={index}>
                    <li>{item.title}</li>
                    <p>{item.content}</p>
                    <button className='btn-del' onClick={()=>this.del(index)}>删除评论</button>
                  </ul>
                </>
              })
            }
          </div>
    </> );
  }
}
 
export default CommentList;